#ifndef GRAPHIC_PHYSIC_BRIDGE_H
#define GRAPHIC_PHYSIC_BRIDGE_H

#include "graphics_engine.h"

#include <btBulletDynamicsCommon.h>
#include <irrlicht.h>

#include <Individual.h>

#include "GraphicEngine.h"

//The GraphicPhysicBridge class describes the software connection between the irrlicht and the bullet library
// all btRigitBody should be created with this motion state in order to be updated in irrlicht rendering
class GraphicPhysicBridge : public btMotionState
{
    //ctors
public:
    GRAPHICS_ENGINE_API explicit GraphicPhysicBridge(const btTransform& initialPosition, irr::scene::ISceneNode *node);
    GRAPHICS_ENGINE_API virtual ~GraphicPhysicBridge(void);

    //interaction
public:
    GRAPHICS_ENGINE_API void getWorldTransform(btTransform &worldTrans) const;
    GRAPHICS_ENGINE_API void setWorldTransform(const btTransform &worldTrans);

    //state
private:
    irr::scene::ISceneNode * const m_node;
    btTransform                    m_position;
};

class BridgeFactory : public MotionStateFactory
{
public:
	GRAPHICS_ENGINE_API explicit BridgeFactory(GraphicEngine&);

public:
	GRAPHICS_ENGINE_API btMotionState* create(
		const btTransform& initialPosition,
		const btVector3&   initialDimension);

private:
	GraphicEngine& m_engine_reference;
	int            m_id_generator;
};

#endif // GRAPHIC_PHYSIC_BRIDGE_H
